package com.swz.dcrm.adpter;

import android.content.Context;

import com.swz.dcrm.R;
import com.swz.dcrm.base.ViewHolder;
import com.swz.dcrm.model.Announcement;
import com.swz.dcrm.util.DateUtils;


import java.util.Date;
import java.util.List;

public class AnnouncementAdapter extends CustomAdapter<Announcement> {
    public AnnouncementAdapter(Context context, List<Announcement> datas) {
        super(context, R.layout.item_announcement, datas);
    }
    @Override
    protected void convert(ViewHolder holder, Announcement announcement, int position) {
        holder.setText(R.id.tv_content,announcement.getContent());
        holder.setText(R.id.tv_date,announcement.getCreateTime());
        holder.itemView.setOnClickListener(v -> {
            setCurrentClickPosition(position);
            if(onClickListener!=null){
                onClickListener.onItemClick(announcement);
            }
        });
        Date date= DateUtils.dateParse(announcement.getEndTime(),"yyyy-MM-dd HH:mm:ss");
        if((new Date()).after(date)){
            holder.setText(R.id.tv_state,mContext.getString(R.string.item_over_time));
        }
    }
}
